import React, {useEffect, useState} from 'react'
import {connect} from "umi";
import SelectSize from "@/pages/Home/component/common/SelectSize";
import './index.less'

const Sizes = (props: any) => {
  const [size, setSize] = useState('')
  const {dispatch} = props

  const getSize = (size: string) => {
    setSize(()=> size)
    dispatch({
      type: 'products/fetchProducts',
      payload: size
    })
  }
  useEffect(()=> {
    getSize('')
  },[])
  return (
    <div className="sizes">
      <div className="title">Sizes:</div>
      <div className="size-group">
        <SelectSize size={size} getSize={getSize}/>
      </div>
    </div>
  )
}
export default connect(({products}: any)=> ({products}))(Sizes) ;

